package com.five.wisdomEat.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.five.wisdomEat.entity.BusinessInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface BusinessInfoMapper extends BaseMapper<BusinessInfo> {

    //查询全部商家信息
    @Select("SELECT * FROM businessinfo")
    List<BusinessInfo> selectBusinessList();

    //根据编号查询商家信息
    @Select("SELECT * FROM businessinfo WHER b_number = #{bNumber}")
    List<BusinessInfo> selectBusinessListByBNumber(String bNumber);

    //添加商家
    @Insert("INSERT INTO businessinfo " +
            "(id,b_number,b_name,b_address,b_phone) " +
            "VALUES (null,#{bNumber},#{bName},#{bAddress},#{bPhone})")
    Integer insertBusiness(BusinessInfo businessInfo);

    //根据商家编号更新商家信息
    @Update("UPDATE businessinfo SET b_name=#{bName},b_address=#{bAddress}" +
            " WHERE b_number = #{bNumber}")
    Integer updateBusiness(BusinessInfo businessInfo);

    //根据商家编号删除商家
    @Delete("DELETE FROM businessinfo WHERE b_number = #{bNumber}")
    Integer deleteBusiness(String bNumber);
}
